package com.remenote.remenoteback.controller;

import com.remenote.remenoteback.entity.req.CommentReq;
import com.remenote.remenoteback.entity.resp.ServerResponse;
import com.remenote.remenoteback.entity.vo.CommentSectionVo;
import com.remenote.remenoteback.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: remenote-back
 * @BelongsPackage: com.remenote.remenoteback.controller
 * @Author: 23392
 * @CreateTime: 2024-03-16  20:49
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    @PostMapping("/make")
    ServerResponse makeComment(@RequestBody CommentReq commentReq) {
        return commentService.makeComment(
                commentReq.getNoteOwnerUserName(),
                commentReq.getNotebookName(),
                commentReq.getNoteTitle(),
                commentReq.getContent());
    }

    @PostMapping("view")
    ServerResponse<CommentSectionVo> viewComment(@RequestBody CommentReq commentReq) {
        return commentService.viewComment(
                commentReq.getNotebookName(),
                commentReq.getNoteTitle(),
                commentReq.getNoteOwnerUserName()
        );
    }

    @PostMapping("delete")
    ServerResponse deleteComment(@RequestBody CommentReq commentReq) {
        return commentService.deleteComment(
                commentReq.getNotebookName(),
                commentReq.getNoteTitle(),
                commentReq.getCreateTime(),
                commentReq.getPublisher()
        );

    }
}
